package com.yyq.gxdc.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yyq.gxdc.entity.DiningTable;
import com.yyq.gxdc.entity.Dish;
import com.yyq.gxdc.entity.ReceivingAddress;
import com.yyq.gxdc.mapper.DiningTableMapper;
import com.yyq.gxdc.mapper.DishMapper;
import com.yyq.gxdc.service.IDiningTableService;
import com.yyq.gxdc.service.IDishService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DiningTableServiceImpl extends ServiceImpl<DiningTableMapper, DiningTable> implements IDiningTableService {
    @Resource
    private DiningTableMapper diningTableMapper;

    @Override
    public PageInfo<DiningTable> findPage(DiningTable conditioin, int pageNum, int pageSize) {
        return PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> {
            diningTableMapper.find(conditioin);
        });
    }
    @Override
    public int add(DiningTable diningTable) {
        return diningTableMapper.insert(diningTable);
    }
    @Override
    public DiningTable findById(Integer id) {
        return diningTableMapper.findById(id);
    }

    @Override
    public DiningTable getDetailByRid(Integer rid){
        DiningTable diningTable = diningTableMapper.findById(rid);

        return diningTable;
    };

    @Override
    public int update(DiningTable dish) {
        return diningTableMapper.updateById(dish);
    }
    @Override
    public int delete(Integer id) {
        return diningTableMapper.deleteById(id);
    }

    @Override
    public IPage<DiningTable> getAllDiningTable(Page<DiningTable> page, DiningTable conditioin){
        return diningTableMapper.getAllDiningTable(page,conditioin);
    };

    @Override
    public List<DiningTable> getUnUseTable(Integer tableType){
        return diningTableMapper.getUnUseTable(tableType);
    }
}

